/**
 * 所有版权归 广西梧州 陈锦韬 所有
 *
 * @Title: CustomAuthenticationEntryPoint
 * @Package com.rx.bean
 * @Description: 重定向
 * @author: 陈锦韬
 * @date: 2020\5\21 0021
 * @version V1.0
 * @Copyright: 2020 陈锦韬  All rights reserved.
 */
package com.rx.core.bean;

import com.alibaba.fastjson.JSON;
import com.rx.core.base.RxBaseConstant;
import com.rx.core.base.RxResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Service;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: Administrator
 * @Description: 重定向
 * @date: 2020\5\21 0021
 */
@Slf4j
@Service
public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
        response.setContentType(RxBaseConstant.APPLICATION_JSON_UTF8_VALUE);
        response.getWriter().write(JSON.toJSONString(RxResponse.logout()));
    }
}
